package com.ltkj.ticket.controller;

import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.ticket.domain.TicVenuesProgramme;
import com.ltkj.ticket.service.ITicVenuesProgrammeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 场馆方案Controller
 * 
 * @author ruoyi
 * @date 2023-09-05
 */
@Api(tags = "场馆方案")
@RestController
@RequestMapping("/programme")
public class TicVenuesProgrammeController extends BaseController
{
    @Autowired
    private ITicVenuesProgrammeService ticVenuesProgrammeService;

    /**
     * 查询场馆方案列表
     */
    @ApiOperation("查询场馆方案列表")
    @RequiresPermissions("ticket:programme:list")
    @GetMapping("/list")
    public TableDataInfo list(TicVenuesProgramme ticVenuesProgramme)
    {
        startPage();
        List<TicVenuesProgramme> list = ticVenuesProgrammeService.selectTicVenuesProgrammeList(ticVenuesProgramme);
        return getDataTable(list);
    }

    /**
     * 导出场馆方案列表
     */
    @ApiOperation("导出场馆方案列表")
    @RequiresPermissions("ticket:programme:export")
    @Log(title = "场馆方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TicVenuesProgramme ticVenuesProgramme)
    {
        List<TicVenuesProgramme> list = ticVenuesProgrammeService.selectTicVenuesProgrammeList(ticVenuesProgramme);
        ExcelUtil<TicVenuesProgramme> util = new ExcelUtil<TicVenuesProgramme>(TicVenuesProgramme.class);
        util.exportExcel(response, list, "场馆方案数据");
    }

    /**
     * 获取场馆方案详细信息
     */
    @ApiOperation("获取场馆方案详细信息")
    @RequiresPermissions("ticket:programme:query")
    @GetMapping(value = "/{venuesProgrammeId}")
    public AjaxResult getInfo(@PathVariable("venuesProgrammeId") Long venuesProgrammeId)
    {
        return success(ticVenuesProgrammeService.selectTicVenuesProgrammeByVenuesProgrammeId(venuesProgrammeId));
    }

    /**
     * 新增场馆方案
     */
    @ApiOperation("新增场馆方案")
    @RequiresPermissions("ticket:programme:add")
    @Log(title = "场馆方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TicVenuesProgramme ticVenuesProgramme)
    {
        return toAjax(ticVenuesProgrammeService.insertTicVenuesProgramme(ticVenuesProgramme));
    }

    /**
     * 修改场馆方案
     */
    @ApiOperation("修改场馆方案")
    @RequiresPermissions("ticket:programme:edit")
    @Log(title = "场馆方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TicVenuesProgramme ticVenuesProgramme)
    {
        return toAjax(ticVenuesProgrammeService.updateTicVenuesProgramme(ticVenuesProgramme));
    }

    /**
     * 删除场馆方案
     */
    @ApiOperation("删除场馆方案")
    @RequiresPermissions("ticket:programme:remove")
    @Log(title = "场馆方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{venuesProgrammeIds}")
    public AjaxResult remove(@PathVariable Long[] venuesProgrammeIds)
    {
        return toAjax(ticVenuesProgrammeService.deleteTicVenuesProgrammeByVenuesProgrammeIds(venuesProgrammeIds));
    }

    @ApiOperation("场馆方案下拉")
    @GetMapping("/listSelect/{ticOtherBaseId}")
    public AjaxResult listSelect( @PathVariable("ticOtherBaseId")String ticOtherBaseId)
    {
        Long aLong = Long.valueOf(ticOtherBaseId);
        List<TicVenuesProgramme> ticVenuesProgrammes = ticVenuesProgrammeService.selectTicVenuesProgrammeSelect(aLong);
        return success(ticVenuesProgrammes);
    }
}
